//
//  ViewController.swift
//  BWExtensionKit
//
//  Created by 1906457616@qq.com on 01/28/2022.
//  Copyright (c) 2022 1906457616@qq.com. All rights reserved.
//

import UIKit
import BWExtensionKit

class DateExtensionsVC: UIViewController {

    @IBOutlet weak var componentsLabel: UILabel!
    @IBOutlet weak var formatsLabel: UILabel!
    @IBOutlet weak var pastsLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        view.backgroundColor = UIColor.blue.reverted
        
        let seconds: TimeInterval = 60
        componentsLabel.text = "\(seconds)秒 = \n" +
        seconds.bw_secondsToDateComponentsJoinedString(units: .cnShort)
        + "\n"
        + seconds.bw_secondsToDateComponentsJoinedString(units: .cnLong)
        + "\n"
        + seconds.bw_secondsToDateComponentsJoinedString(units: .enShort)
        + "\n"
        + seconds.bw_secondsToDateComponentsJoinedString(units: .enLong)
        + "\n"
        
        let date = Date()
        formatsLabel.text = "Now: \n"
        + date.bw_toString(components: .full, dateJoinTag: .line1, timeJoinTag: .colon)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .line1, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .line1, timeJoinTag: .cn2)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .cn2, timeJoinTag: .cn2)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .cn1, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .dot1, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .dot2, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .slash1, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .slash2, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .line2, timeJoinTag: .cn1)
        + "\n"
        + date.bw_toString(components: .full, dateJoinTag: .comma, timeJoinTag: .cn1)
        + "\n"
        
        let pastDate = Date(timeIntervalSinceNow: -6)
        pastsLabel.text = "\(pastDate): \n"
        + pastDate.bw_toPassedTimesString(locale: .en)
        + "\n"
        + pastDate.bw_toPassedTimesString(locale: .cn)
        + "\n"
    }
}

